package com.koron.css2.meterService.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.meterService.bean.MsChangeHistoryBean;
import com.koron.css2.meterService.bean.query.MsChangeHistoryQuery;
import com.koron.css2.meterService.mapper.MsChangeHistoryMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;
/**
 *
 * 表计变更历史查询
 * */
public class MsChaHistoryQuery implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        MessageBean<List> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "查询成功", List.class);
        try {
            MsChangeHistoryQuery msChangeHistoryQuery = JsonUtils.objectToPojo(req.getData(), MsChangeHistoryQuery.class);
            MsChangeHistoryMapper mapper = factory.getMapper(MsChangeHistoryMapper.class);
            List<MsChangeHistoryBean> msChangeHistoryBeans = mapper.queryByDifferentConditions(msChangeHistoryQuery);
            info.setData(msChangeHistoryBeans);

            return info;

        } catch (Exception e) {
            info.setCode(Constant.MESSAGE_INT_FAIL);
            info.setDescription("变更历史查询");
            logger.error(e.getMessage(), e);
        }
        return info;
    }
}
